<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    
</body>
</html>
<script>
    function f1(){
        console.log("第一个函数");
    }
    function f2(){
        console.log("第二个函数");
    }

    class Event{
        constructor(){
            this.wrap = {}
        }

        on(key,data){
            if(!this.wrap[key]){
                this.wrap[key] = [data];
            }else{
                this.wrap[key].push(data);
            }
            console.log(this.wrap);
        }
        fire(key){
            for(const keys in this.wrap){
                if(key == keys){
                this.wrap[key].forEach(f => {
                    f();
                })
                }else{
                    console.error("密码输入错误")
                }
            }       
        }
    }
    const vm = new Event();
        
</script>